import re


class Student(object):
    def __init__(self ,number ,name ,age ,sex):
        self.number = number
        self.name = name
        self.age =age
        self.sex = sex
        self.height = 0
        self.soc = 0
        self.add = ''
        self.phoneNum = ''

    def study(self ,time):
        print(self.name ,'学习了' ,time ,'分钟')

    def playGame(self ,gameName):
        print(self.name ,'正在玩' ,gameName)

    def biancheng(self ,rows):
        print(self.name ,'敲了' ,rows ,'行代码')

    def adds(self ,*nums):
        addNums = 0
        for i in nums:
            addNums = addNums + i
        return addNums


class Car(object):
    def __init__(self ,num ,chelun ,color ,weight ,cap):
        self.num =num
        self.chelun = chelun
        self.color =color
        self.weight = weight
        self.cap =cap

    def run(self ,character):
        print(character ,'是一个型号为' ,self.num ,',车轮为' ,self.chelun ,',颜色为' ,self.color ,'的一辆车')


class People(object):
    def __init__(self ,name ,sex ,age ,money ,phoneName ,phonecap = 0 ,phoneRange = 0 ,phoneTime = 0 ,phonesoc = 0):
        self.name = name
        self.sex = sex
        self.age = age
        self.money = money
        self.phoneName = phoneName
        self.phonecap = phonecap
        self.phoneRange =phoneRange
        self.phoneTime =phoneTime
        self.phonesoc =phonesoc

    def sendMessage(self ,message):
        print('发送成功，发送的消息为:' ,message)

    def callNumber(self ,phoneNumber ,time):
        try:
            re.match('[0-9]{11}', phoneNumber).span() != (0, 11)
            if self.money <= 1:
                raise  ValueError('余额不足')
        except AttributeError as e:
            print('电话号码错误')
        except ValueError as e:
            print(e)
        else:
            if time <= 10:
                self.money = self.money - time * 1
                self.phonesoc = self.phonesoc + time * 15
            elif time <= 20:
                self.money = self.money - 10 - (time - 10) * 0.8
                self.phonesoc = self.phonesoc + 150 + (time - 10) * 39
            else:
                self.money = self.money - 18 - (time - 20) * 0.65
                self.phonesoc = self.phonesoc + 540 + (time - 20) * 48
            print('完成通话')
            print('您的余额还有' ,self.money ,'  积分为' ,self.phonesoc)




student =Student(1 ,'张三' ,18 ,'男')
student.study(20)
student.playGame('王者荣耀')
student.biancheng(200)
print(student.adds(2, 3, 4, 5, 6))
print()
print()
car1 = Car('1138' ,4 ,'红色' ,400 ,500)
car2 = Car('1139' ,4 ,'蓝色' ,400 ,500)
car3 = Car('1140' ,4 ,'绿色' ,400 ,500)
car4 = Car('1141' ,4 ,'黄色' ,400 ,500)
car5 = Car('1142' ,4 ,'紫色' ,400 ,500)
car1.run('宝马')
car2.run('法拉利')
car3.run('林沐')
car4.run('五零')
car5.run('拖拉机')
people = People('张三' ,'男' ,18 , 10.0 ,'梨子')
people.sendMessage('张三你好你是个***')
people.callNumber('10125656428' ,23)
